package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/count-pairs-with-xor-in-a-range/
 *
 * @author yulongTian
 * @create 2023-01-05 17:30
 */
public class Test04 {
    public static void main(String[] args) {
        int[] nums = {9, 8, 4, 2, 1};
        int low = 5;
        int high = 14;
        System.out.println(countPairs(nums, low, high));
    }

    public static int countPairs(int[] nums, int low, int high) {
        int ans = 0;
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                int temp = nums[i] ^ nums[j];
                if (temp >= low && temp <= high) {
                    ans++;
                }
            }
        }
        return ans;
    }

}
